import 'package:flutter/material.dart';

class NewsLinePainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    Paint paint = Paint()
      ..color = Colors.grey
      ..strokeWidth = 0.5
      ..style = PaintingStyle.stroke;

    // 绘制垂直虚线，从上到下
    double dashHeight = 5; // 虚线的每段长度
    double dashSpace = 10; // 虚线的间隔
    for (double i = 0; i < size.height; i += dashHeight + dashSpace) {
      canvas.drawLine(
        Offset(30, i), // 线的起点
        Offset(30, i + dashHeight), // 线的终点
        paint, // 画笔
      );
    }

    // canvas.drawLine(
    //   const Offset(30, 0),
    //   Offset(30, size.height),
    //   paint,
    // );

    // double dashWidth = 5; // 虚线的每段长度
    // double dashSpace = 5; // 虚线的间隔

    // // 绘制虚线，从左上角到右下角
    // for (double i = 0; i < size.width; i += dashWidth + dashSpace) {
    //   canvas.drawLine(
    //     Offset(i, 0), // 线的起点
    //     Offset(i + dashWidth, 0), // 线的终点
    //     paint, // 画笔
    //   );
    // }
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) {
    return false;
  }
}
